Skip to content

dgb(share): rewire weight-decay arithmetic onto coin/share_weight_decay.hpp SSOT (#450 follow-on, value-invariant) - #526

Closed
frstrtr wants to merge 1 commit into
masterfrom
dgb/share-weight-decay-rewire
Closed

dgb(share): rewire weight-decay arithmetic onto coin/share_weight_decay.hpp SSOT (#450 follow-on, value-invariant)#526
frstrtr wants to merge 1 commit into
masterfrom
dgb/share-weight-decay-rewire

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 26, 2026

Copy link
Copy Markdown
Owner

#450 follow-on — share_weight_decay SSOT rewire (work-only, NO self-merge)

Closes the FENCED-but-not-rewired state of the #450 SSOT lift. The three open-coded copies of the V36 PPLNS exponential weight-decay rate in src/impl/dgb/share_tracker.hpp now delegate to coin/share_weight_decay.hpp:

site before after
DensePPLNSWindow::init_decay_table inline half_life/decay_per literals weight_decay::decay_per_share()
get_v36_decayed_cumulative_weights (hot path) inline literals weight_decay::half_life/decay_per_share + DECAY_SCALE/DECAY_PRECISION
dump_v36_pplns_walk (GENTX-mismatch diag) inline literals same SSOT helpers

Zero 693147 literals remain in share_tracker.hpp.

Byte-identity discipline (the line drawn, per integrator)

  • The uint288 hot-path decayed-attempts widening stays open-coded ((att * uint288(decay_fp)) >> 40).
  • The mul128_shift decay_fp walk stays open-coded.
  • Only the rate constants + half_life() + decay_per_share() move to the SSOT. The wire/consensus bytes are untouched.

Value-invariance KAT (the merge proof)

dgb_share_weight_decay_test:

  • RewireConstantsValueInvariant — old open-coded half_life/decay_per literal expressions vs SSOT helpers over a chain-length sweep {8640,2880,3600,720,100,8,4,3,1,0}.
  • DecayedCumulativeWeightVectorInvariant — recomputes the full decayed-cumulative-weight vector (addr-weight + total-weight accumulators) over depth×64 × chain-length {8640,2880,720,4} × att/donation matrix, OLD literal expressions vs SSOT helpers, asserts equality at every depth + on the cumulative totals. mul128_shift is reproduced verbatim (same on both arms → cancels).

Scope

  • FENCED to src/impl/dgb/ only — no shared/bitcoin_family/core touch.
  • Only share_tracker.hpp (rewire) + share_weight_decay_test.cpp (KAT) changed. No build.yml / CMakeLists churn (test + target pre-exist).

Local verification (head d14d43c)

  • dgb_share_weight_decay_test: 8/8 PASS (incl. 2 new invariance KATs)
  • dgb_share_test: 34/34 PASS (production TU consuming the rewired header compiles + passes)
  • Commit GPG-signed (Good signature).

NO self-merge — consensus version/acceptance-adjacent surface: integrator value-diffs, then operator tap.

…ay.hpp SSOT

Delegate the three open-coded copies of the V36 PPLNS exponential
weight-decay rate (DensePPLNSWindow::init_decay_table,
get_v36_decayed_cumulative_weights, dump_v36_pplns_walk) onto the #450
coin/share_weight_decay.hpp SSOT: half_life(), decay_per_share() and the
DECAY_SCALE/DECAY_PRECISION constants now come from one source instead of
three inline literal copies of

    half_life = max(chain_length / 4, 1)
    decay_per = SCALE - (SCALE * 693147) / (1e6 * half_life)

Byte-identity preserved: the uint288 hot-path decayed-attempts widening and
the mul128_shift decay_fp walk stay open-coded (the consensus/wire bytes);
only the rate constants + half_life/decay_per move to the SSOT. Zero 693147
literals remain in share_tracker.hpp.

A value-invariance KAT (DgbWeightDecay.RewireConstantsValueInvariant +
DecayedCumulativeWeightVectorInvariant) recomputes the full decayed-
cumulative-weight vector over a depth(64) x chain-length sweep via the OLD
literal expressions vs the SSOT helpers and asserts equality.

FENCED to src/impl/dgb/; no shared/bitcoin_family/core touch. No build.yml
or CMakeLists churn (test + target pre-exist).
@frstrtr

frstrtr commented Jun 26, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #525 (merged @470892d50) which landed the identical weight-decay arithmetic rewire onto coin/share_weight_decay.hpp SSOT. Net diff vs master is fully subsumed (constants->DECAY_PRECISION/DECAY_SCALE, decay_per->decay_per_share(), half_life->half_life() at all three sites). Closing as redundant; branch preserved (no --delete-branch).

@frstrtr frstrtr closed this Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant